<template>
    <h1>借款款项信息显示页面</h1>

    <BorrowAll v-slot="info">
        <a href="#" @click="DelData(info.id)" >删除</a>&nbsp;&nbsp;
        <a href="#" @click="jump(info.id)" >修改</a>&nbsp;&nbsp;
    </BorrowAll>
    
</template>

<script setup lang="ts">

import BorrowAll from '../Borrow/BorrowAll.vue'
import axios from 'axios'
import { useRouter } from 'vue-router'

const router = useRouter()



const DelData = (Id:string) =>{

    if(confirm('确定要删除吗？')){
        
        axios({
        method:'get',
        url:'http://localhost:63517/api/Borrow/DelData',
        params:{
            Id:Id
        }
    })
    .then(res=>{
        if(res.data>0){
            alert('删除成功')
        }
        else{
            alert('删除失败');
            return;
        }
    })
    .catch(err=>{
        console.log(err);
    })

    }
    
}

const jump = (Id:string) =>{
    router.push({
        name:'EditBorrow',
        params:{
            Id:Id
        }
    })
}


</script>
